package com.design_pattern._02_structure._04_proxy;

import java.util.Date;

public class V4 {
    public static void main(String[] args) {
        Movable move = new Tank();
        Movable logProxy = new TankLogProxy(move);
        Movable proxy = new TankStatusProxy(logProxy);
        proxy.move();
    }
}

class TankLogProxy implements Movable{
    private Movable move;
    public TankLogProxy(Movable move){
        this.move = move; // 这里也可以直接new出来Tank
    }
    @Override
    public void move() {
        System.out.println("start in " + new Date().getTime());
        move.move();
        System.out.println("stop in " + new Date().getTime());
    }
}
class TankStatusProxy implements Movable{
    private Movable move;
    public TankStatusProxy(Movable move){
        this.move = move; // 这里也可以直接new出来Tank
    }
    @Override
    public void move() {
        System.out.println("运行前状态: " + "good");
        move.move();
        System.out.println("运行后状态: " + "good");
    }
}

